/*
 *  @product.title@
 *  Copyright (C) @product.copyright-year@
 *    @product.vendor@
 *    Registration Number: @product.registration-number@
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package jp.go.aist.six.util.persist;

import java.util.Collection;
import java.util.List;
import jp.go.aist.six.util.search.Binding;
import jp.go.aist.six.util.search.Limit;
import jp.go.aist.six.util.search.Order;
import jp.go.aist.six.util.search.SearchCriteria;



/**
 * A data store facade that supports multiple types of objects.
 *
 * @author  Akihito Nakamura, AIST
 * @version $Id: Datastore.java 317 2011-06-16 03:01:05Z nakamura5akihito $
 */
public interface Datastore
{

    public <K, T extends Persistable<K>>
    K create( Class<T> type, T object )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    void update( Class<T> type, T object )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    void remove( Class<T> type, T object )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    T sync( Class<T> type, T object )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    List<T> syncAll( Class<T> type, List<? extends T> objects )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    int count( Class<T> type )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    int count( Class<T> type, Binding filter )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    T load( Class<T> type, K id )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    List<T> loadAll( Class<T> type, List<? extends K> ids )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    Collection<T> find( Class<T> type )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    Collection<T> find( Class<T> type, Binding filter )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    Collection<T> find( Class<T> type, Binding filter, List<? extends Order> ordering, Limit limit )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    Collection<K> findIdentity( Class<T> type )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    Collection<K> findIdentity( Class<T> type, Binding filter )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    Collection<K> findIdentity( Class<T> type, Binding filter, List<? extends Order> ordering, Limit limit )
    throws PersistenceException;


    public <K, T extends Persistable<K>>
    List<Object> search( Class<T> type, SearchCriteria criteria )
    throws PersistenceException;

}
// Datastore
